package com.microservices.yucloud.appweb.controller;

import com.microservices.yucloud.appweb.domain.Orders;
import com.microservices.yucloud.appweb.domain.StateMachineRequest;
import com.microservices.yucloud.appweb.service.OrderFlowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zy
 * @date 2019-08-28 19:09
 **/
@Slf4j
@RestController
@RequestMapping("/state-machine")
public class StateMachineController {

    @Autowired
    private OrderFlowService orderFlowService;

    @GetMapping("/create")
    public String testStateMachine() {
        Orders orders = new Orders();
        orders.setId("1");
        orders.setState("1");
        orders.setUserId("123");
        orders.setAddress("aaa");
        orders.setPhoneNum("13311111111");
        StateMachineRequest<Orders> request = new StateMachineRequest<>();
        request.setBizCode(orders.getId());
        request.setBizModel(orders);
        orderFlowService.createOrder(request);
        return "ok";
    }
}
